<template>
  <div class="header wrap">
    <h1>
      <img src="../assets/img/indexLogo.png" alt="" class="logo" />
    </h1>
    <div class="nav">
      <ul>
        <li @click="$router.push('/home')" :class="$route.path === '/home' ? 'active' : ''">首页</li>
        <li @click="$router.push('/goods')" :class="$route.path === '/goods' ? 'active' : ''">全部礼品</li>
        <li @click="$router.push('/user')" :class="$route.path === '/user' ? 'active' : ''">个人中心</li>
        <li @click="$router.push('/order')" :class="$route.path === '/order' ? 'active' : ''">我的订单</li>
        <li @click="$router.push('/free')" :class="$route.path === '/free' ? 'active' : ''">专属福利</li>
      </ul>
    </div>
    <div class="search">
      <input type="text" v-model="userinputsearch" @keyup.13="tosearch">
      <span @click="tosearch"><img width="15" height="15" src="../assets/img/search.png" alt="" /></span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      userinputsearch: ''
    }
  },
  methods: {
    tosearch() {
      this.$router.push(`/goods?keyword=${this.userinputsearch}`)
      this.userinputsearch=''
    }
  }
};
</script>

<style lang="scss" scoped>
.header {
  height: 118px;
  display: flex;
  align-items: center;
  justify-content: space-between;

  .nav ul {
    display: flex;
    width: 500px;
    justify-content: space-between;

    li {
      cursor: pointer;
    }

    .active {
      color: #0a328e;
      font-weight: 700;
    }
  }

  .search {
    display: flex;

    input {
      width: 214px;
      height: 38px;
      border: 1px solid #dedede;
      border-radius: 20px 0 0 20px;
      text-indent: 15px;
    }

    span {
      width: 50px;
      height: 40px;
      background: #0a328e;
      border-radius: 0 20px 20px 0;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
    }
  }
}</style>